-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name unions #1027
Name unions #1027
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I would add a compiler check that verifies that if codegen_names
is present, then the number of identifiers should be the same as the union members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left two questions, not sure if they're applicable, though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Add "@codegen_names" jstag to identify union members * Extract unions to named types, and fix some type declarations * Add boolean/enum leniency to the TS generator
Most strongly typed languages need each member of a union type to have an identifier. In Java we generate custom wrappers for unions, Rust needs names for enum variants (Rust unifies enums and tagged unions).
This PR updates the spec to change inline unions used in property declarations to a distinct type with a new
@codegen_names
(plural) annotation that names the union members.becomes
Some inline unions are left in the spec, that represent the leniency rules that ES implements. These are notably
SomeType | SomeType[]
(read a single object as a 1-sized array) and strings that accept any primitive type.These leniency rules are currently implemented in the Java generator and will later be formalized as new model validation rules that will report inline unions that require a separate type definition.
Along with refactoring enumerations to enum types, this PR also fixes a number of definitions that were ambiguous or actually wrong. API validation has been run on most of these changes to verify that there were no regressions.
Validation of the
search
API has 3 errors less, and the remaing ones are because of the use of numbers for ids (they're not quoted in the YAML tests) and experimentalbucket_correlation
andbucket_count_ks_test
aggregations that have not been represented in the spec.